<?php

namespace Library\Widget\Options;

class Group extends \Library\Widget {

	private $_title;
	private $_key;
	private $_parent;
	private $_options = array();
	private $_attributes = array();
	
	public function __construct( $key, \Library\Widget\Options $parent ) {
		parent::__construct();
		$this->_key = $key;
		$this->_parent = $parent;
	}
	
	public function getKey() {
		return $this->_key;
	}
	
	public function getParent() {
		return $this->_parent;
	}
	
	public function setTitle( $title ) {
		$this->_title = $title;
		return $this;
	}
	
	public function getTitle() {
		return $this->_title;
	}

	public function getOption( $key ) {
		if( !isset($this->_options[ $key ]) ) {
			$this->_options[ $key ] = new Option( $key, $this );;
		}
		return $this->_options[ $key ];
	}
	
	public function getOptions() {
		return $this->_options;
	}
	
	public function setAttribute( $key, $value ) {
		$this->_attributes[ $key ] = $value;
		return $this;
	}
	
	public function getAttributes() {
		return $this->_attributes;
	}
	
	public function isEmpty() {
		return !$this->_options;
	}
}
